# SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
# SPDX-License-Identifier: Mulan PSL v2
#!/bin/bash
set -e


NEW_USER_ID="$1"
S3_SERVER="$2"
ADMIN_ACCESS="$3"
ADMIN_SECRET="$4"

USER_NAME="${NEW_USER_ID}"
BACKET_NAME="${NEW_USER_ID}"

mc alias set aip_system_s3 "${S3_SERVER}" "${ADMIN_ACCESS}" "${ADMIN_SECRET}"
mc rb --force aip_system_s3/"${BACKET_NAME}"
mc admin policy unset aip_system_s3 "${BACKET_NAME}" user="${USER_NAME}"
mc admin policy remove aip_system_s3 "${BACKET_NAME}"
mc admin user remove aip_system_s3 "${USER_NAME}"
